﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLDC.Common.Estate;
using ZLDC.Topo.Model.Estate;
using System.Text;
using ZLDC.Topo.BLL.Estate;

namespace ZLDC.Estate.CM
{
    public partial class Area : _PageBase
    {
        private static string CityIdList = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            CityIdList = _Request.GetString("CityId","");
            LoadArea();
        }
        // 加载片区
        private void LoadArea()
        {
            int parentid = 1;       // 深圳
            StringBuilder sb = new StringBuilder();

            sb.Append("<table style=\"width: 98%; background:#000000; \" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" >");
            sb.Append("<tr style=\"background-color:#F1FADE; text-align:center; font-weight:bold;\"><td style=\"width:10%;\">城区</td>");
            sb.Append("<td>片区</td>");
            sb.Append("</tr>");
            List<AreaInfo> list = null;
            if (CityIdList == "")
            {
                list= ZLDC.Topo.BLL.Estate.AreaBLL.AreaList2(parentid);
            }
            else 
            {
                list = ZLDC.Topo.BLL.Estate.AreaBLL.AreaList3(parentid,CityIdList);
  
            }
                if (list != null && list.Count > 0)
                {
                    int num = 0;
                    foreach (AreaInfo item in list)
                    {
                        List<AreaInfo> list2 = ZLDC.Topo.BLL.Estate.AreaBLL.AreaList2(item.Id);

                        sb.Append("<tr>");
                        sb.Append("<td style=\"background:#FFFFFF;\">" + item.Name + "</td>");
                        sb.Append("<td style=\"background:#FFFFFF;\">");
                        sb.Append("<table style=\"width: 100%; \"><tr>");
                        for (int i = 0; i < list2.Count; i++)
                        {
                            AreaInfo item2 = list2[i];

                            if (i > 0 && i % 8 == 0)
                            {
                                sb.Append("</tr><tr>");
                            }

                            sb.Append("<td>");
                            sb.Append("<input id=\"cbArea_" + num + "\"  value='" + item2.Id + "' name='cbArea' type=\"checkbox\"  />");
                            sb.Append(item2.Name);
                            sb.Append("<input id=\"Area_" + num + "\" value='" + item2.Name + "' type='hidden' />");
                            sb.Append("</td>");
                            num = num + 1;
                        }

                        sb.Append("</tr></table>");
                        sb.Append("</td>");
                        sb.Append("</tr>");
                    }
                }

            sb.Append("</table>");

            divArea.InnerHtml = sb.ToString();
        }
    }
}
